<div class="plaza-tip-con">
    <p>易仔温馨提示：工程师在在努力建设当中，敬请期待哦！</p>
</div>
<?php /** @var User $CurrentUser */ ?>
<div id="top-header-top">
    <div class="top-header-top-box">
        <div id="top-header-location">
            <span><?php echo $currentSchool['schoolname'] ?></span>
            <a class="changeschool" href="javascript:void(0);">[切换]</a>
        </div>
        <div id="top-header-user">
            <?php if (isset($CurrentUser) && $CurrentUser->getId() !== 0): ?>
                <div class="user-name">
                    <a href="<?php echo base_url('home/userCenter'); ?>">
                        <span><?php echo $CurrentUser->getDisplayName(); ?></span>
                    </a>
                    <a class="signOut" href="javascript:"> [退出]</a>
                </div>
                <a href="<?php echo base_url('home/userCenter/message'); ?>" target="_blank" class="user-message" title="查看留言"><img src="<?php echo base_url('public/images/tip-pic2.png'); ?>"/></a>
                <!--
                <a href="<?php echo base_url('home/official'); ?>" target="_blank" class="user-message" title="查看官方消息" style="position:relative;">
                    <img src="<?php echo base_url('public/images/tip-pic1.png'); ?>"/>
                    <span class="red-dot"></span>
                </a>
                -->
                <a href="<?php echo base_url('home/userCenter#user-avatar'); ?>" class="user-pic"><img class="user-avatar" src="<?php echo $CurrentUser->getDisplayAvatarUrl() ?>" title="编辑用户头像"/></a>
            <?php else: ?>
                <span class="user-name">游客</span>
                <span class="user-login"><a class="signIn" href="javascript:">登录</a><span class="line">/</span><a class="signUp" href="javascript:">注册</a></span>
            <?php endif; ?>
        </div>
    </div>
</div>
<div id="top-header">
    <div id="top-header-nav">
        <a href="<?php echo base_url(); ?>" <?php if ($this->router->fetch_method() === 'index') echo 'class="active"'; ?>>首页</a>
        <a href="<?php echo base_url('home/commodityRequire'); ?>" <?php if ($this->router->fetch_method() === 'commodityRequire') echo 'class="active"'; ?>>求购区</a>
        <?php if ($CurrentUser->getId()): ?>
            <a href="<?php echo base_url('home/userCenter/commodity'); ?>" <?php if ($this->router->fetch_method() === 'userCenter' && $thatUser->getId() == $CurrentUser->getId()) echo 'class="active"'; ?>>我的易米</a>
        <?php endif; ?>
        <div id="plaza" class="plaza-tip-btn">
            <a href="javascript:void(0);">易米广场</a>
            <!--
            <ul class="plaza-son-nav">
                <li><a href="<?php echo base_url('home/plaza') ?>" <?php if ($this->router->fetch_method() === 'plaza') echo 'class="active"'; ?>>学校周边</a></li>
            </ul>
            -->
        </div>
        <div class="aside" style="padding:0;">
            <a href="javascript:" class="feedback-btn">反馈建议</a><span class="line">|</span><a href="<?php echo base_url('home/aboutus') ?>" target="_blank">关于我们</a>
        </div>
    </div>
</div>
<?php if ($this->router->fetch_method() !== 'aboutus' && $this->router->fetch_method() !== 'weibologin' && $this->router->fetch_method() !== 'weiboregister' && $this->router->fetch_method() !== 'official' && $this->router->fetch_method() !== 'result_show' && $this->router->fetch_method() !== 'resetpwd' && $this->router->fetch_method() !== 'resetpassword'): ?>
    <div id="top-header-check">
        <a href="<?php echo base_url(); ?>" id="top-header-site-logo"><img src="<?php echo base_url('public/images/logo_w.png'); ?>"/></a>

        <form class="search-box" id="search-box">
            <input type="text" class="search-str" id="search" name="search-str" placeholder="输入搜索内容"/>
            <input type="submit" class="search-submit-btn" value="搜  索"/>
        </form>
        <div id="quick-btn">
            <a href="javascript:" class="wantToSell">发布出售</a>
            <span class="quick-btn-line"></span>
            <a href="javascript:" class="wantToBuy">发布求购</a>

        </div>
    </div>
<?php endif; ?>

<?php if ($this->router->fetch_method() != 'weibologin' && $this->router->fetch_method() !== 'weiboregister'): ?>
    <div id="top-header-show">
        <div style="position:relative;">
            <a href="<?php echo base_url(); ?>" id="top-header-show-logo"><img src="<?php echo base_url('public/images/logo_w.png'); ?>"/></a>

            <div id="top-header-show-center">
                <div id="top-header-show-nav">
                    <a href="<?php echo base_url(); ?>" <?php if ($this->router->fetch_method() === 'index') echo 'class="active"'; ?>>首页</a>
                    <a href="<?php echo base_url('home/commodityRequire'); ?>" <?php if ($this->router->fetch_method() === 'commodityRequire') echo 'class="active"'; ?>>求购区</a>
                    <?php if ($CurrentUser->getId()): ?>
                        <a href="<?php echo base_url('home/userCenter'); ?>" <?php if ($this->router->fetch_method() === 'userCenter' && $thatUser->getId() == $CurrentUser->getId()) echo 'class="active"'; ?>>我的易米</a>
                    <?php endif; ?>
                    <div id="plaza2" class="plaza-tip-btn">
                        <a href="javascript:void(0);">易米广场</a>
                        <!--
                <ul class="plaza-son-nav">
                    <li><a href="<?php echo base_url('home/plaza') ?>" <?php if ($this->router->fetch_method() === 'plaza') echo 'class="active"'; ?>>学校周边</a></li>
                </ul>
                -->
                    </div>
                </div>
            </div>
            <div id="quick-btn" style="float:right;">
                <a href="javascript:" class="wantToSell">发布出售</a>
                <a href="javascript:" class="wantToBuy">发布求购</a>
            </div>
        </div>
    </div>
<?php endif; ?>

<?php if (isset($NewMsgCount) && $NewMsgCount && $this->router->fetch_method() !== 'userCenter'): ?>
    <div class="msg-tips">
        <a href="<?php echo base_url('home/userCenter/message/' . $CurrentUser->getId()) ?>"><?php echo $NewMsgCount ?>条未读消息</a>
        <span class="msg-tips-close" title="暂时关闭消息提醒">x</span>
    </div>
<?php endif ?>

<script>
    $(function () {
        $("#plaza,#plaza2").mouseenter(function () {
            $(this).children(".plaza-son-nav").css("display", "block");
            $(this).addClass("active");
        });
        $("#plaza,#plaza2").mouseleave(function () {
            $(this).children(".plaza-son-nav").css("display", "none");
            $(this).removeClass("active");
        });
    });
</script>
<script>
    $(function () {
        $(".msg-tips-close").on('click', function () {
            $(".msg-tips").css("display", "none");
        });
    });
</script>
<script>
    $(function () {
        $('#search').autocomplete('<?php echo base_url('api/getTagName') ?>', {
            minChars: 0,        //至少输入的字符数，default：1；
            max: 5,            //下拉项目的个数，default：10
            scrollHeight: 300,    // 下拉框的高度， Default: 180
            scroll: true,        //当结果集大于默认高度时，是否使用滚动条，Default: true
            multiple: false,    //是否允许输入多个值. Default: false
            dataType: "json",
            parse: function (data) {
                return $.map(data['keywords'], function (row) {
                    return {
                        data    : row,
                        id      : row.id,
                        keyword : row.name,
                        value   : row.values
                    }
                });
            },
            formatItem: function (item) {
                return item.name;
            }
        }).result(function (e, item) {
            $('#search').val(item.values);
        });
    });
</script>

<script>
    $(function () {
        $(window).scroll(function () {
            if ($(window).scrollTop() > 100) {
                $("#top-header-show").stop().animate({top: 0}, 200,
                    function () {
                        $(".search-box").css("position", "fixed");
                        $(".search-box").css("z-index", "1001");

                        $(".search-box").css("width", "400px");
                        $("#search").css("width", "290px");
                        $(".search-box").css("right", "50%");
                        $(".search-box").css("margin-right", "-360px");
                        $(".search-box").css("top", "-10px");
                        $(".ac_results").animate({width: "310px"}, 1);
                    }
                );
            }
            if ($(window).scrollTop() < 120) {
                $("#top-header-show").stop().animate({top: -80}, 200);
                $(".search-box").css("position", "");
                $(".search-box").css("z-index", "");
                $(".search-box").css("top", "");
                $(".search-box").css("width", "560px");
                $("#search").css("width", "450px");
                $(".search-box").css("right", "");
                $(".search-box").css("margin-right", "");
                $(".ac_results").animate({width: "470px"}, 1);
            }
        });
    });
</script>
<script>
    $(".plaza-tip-btn").on("click", function () {
        $(".plaza-tip-con").css("display", "block");
        setTimeout(function () {
            $(".plaza-tip-con").css("display", "none");
        }, 1000);
    })
</script>